<template>
	<view class="file-share-container">
		<view class="file-info">
			<view style="text-align: center;">
				{{ fileName }}
			</view>
			<view style="margin-top: 32rpx;">
				<van-button open-type="share" type="primary">
					分享给好友
				</van-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data () {
			return {
				filePath: '',
				fileName: '',
				shareData: {
					title: '分享文件',
					path: '/pages/fileDetail/fileDetail',
					imageUrl: '',
					content: '',
					desc: ''
				}
			}
		},
		onLoad(e) {
			this.filePath = e.filePath
			this.fileName = e.fileName
			this.shareData.content = this.fileName
			this.shareData.desc = this.fileName
		},
		onShareAppMessage (res) {
			const shareDict = {
				fileName: this.fileName,
				filePath: this.filePath
			}
			const shareStr = JSON.stringify(shareDict)
			return {
				title: this.shareData.title,
				path: `pages/fileDetail/fileDetail?fileObj=${shareStr}`,
				// path: `/pages/fileDetail/fileDetail?filePath=${item.path}&fileName=${item.name}`,
				imageUrl: this.shareData.imageUrl,
				content: this.shareData.content,
				desc: this.shareData.desc,
				success: res => {
					console.info(res)
				}
			}
		}
	}
</script>

<style lang="scss">
.file-share-container{
	width: 100vw;
	height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
}
</style>
